package cn.hr.interceptor;
/**                                        
 *功能描述:通用日志类，记录整个系统运行期的日志
 * @author  梁耀天             
 * @version   1.0                     
 * create Date April 21, 2010
 */ 
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.aspectj.lang.ProceedingJoinPoint;

public class CommonLogger {
	private static Logger logger = LogManager.getLogger(CommonLogger.class);   
	
    public Object invoke(ProceedingJoinPoint joinPoint) throws Throwable { 
  
        try{
        	logger.info("Starting method:"+joinPoint.getTarget().getClass() + "." + joinPoint.getSignature().getName() + "() " );
            Object result = joinPoint.proceed(); 
            return result;   
        }catch(Exception e){   
            logger.info(  joinPoint.getTarget().getClass() + "." + joinPoint.getSignature().getName() + "() invoke error" );   
            logger.info("error info ["+e.getMessage()+"]");   
        }finally{   
            logger.info("Ending method:" + joinPoint.getTarget().getClass() + "." + joinPoint.getSignature().getName() + "()");   
//            logger.info("Method invocation time:" + (System.currentTimeMillis() - startTime) + " ms.");              
        }   
        return null;   
    } 
}
